#include "bezier_label.h"
#include <QPainter>

Bezier_Label::Bezier_Label(QWidget *parent):QLabel(parent)
{

}

void  Bezier_Label::paintEvent(QPaintEvent *event)
{
    QLabel::paintEvent(event);

    QPainter bezier_painter;
    bezier_painter.begin(this);

    bezier_painter.setPen(QPen(Qt::red, 4, Qt::SolidLine, Qt::RoundCap));

    float width_t = map_width_pixel / map_width;
    float height_t = map_width_pixel / map_width;

    /*平移、旋转坐标系*/
    bezier_painter.translate(translate_dx * width_t, translate_dy * height_t);
    bezier_painter.rotate(translate_dangle);

    /*画坐标点*/
    for (int i = 0; i <= bezier_cnt; i++)
    {
        for(int j = 0; j <= bezier_path[bezier_cnt].out_num; j++)
        {
            bezier_painter.drawPoint(-bezier_path[bezier_cnt].out_points[j].X * width_t,
                                      bezier_path[bezier_cnt].out_points[j].Y * height_t);
        }
    }
    bezier_painter.end();
}
